package com.fifth.apartment.controller;


import com.fifth.apartment.entity.Orders;
import com.fifth.apartment.result.Result;
import com.fifth.apartment.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/orders")
@Api(tags ="订单接口")
@Slf4j
public class OrdersController {

    @Autowired
    private OrderService orderService;

    @PostMapping("add")
    @ApiOperation("新增订单接口")
    public Result add(){
        Orders orders = orderService.add();
        return new Result(true , "订单新增成功" , orders);
    }

    @GetMapping("{id}")
    @ApiOperation("查询订单接口")
    public Result find(@PathVariable("id")int id){
        Orders orders = orderService.find(id);
        return new Result(true , "查询订单成功" , orders);
    }
}
